For Next

Syntax: @For variable = startvar to endvar [step increment]

The For Next command can be used to perform looping, with an optional incremental step value, default 1. The Variable to be used as the counter can be any type of numeric (attribute, array, etc.). Startvar, endvar and increment (positive or negative) can be literal numeric values or numeric variables. The Next command can be followed by the variable name of previous For command, or used alone.

Examples

@For Count = 1 to 100
@Assign Num[1] = 0
@Next

a basic For Next loop

@For Count = Start to End Step 5
@For Value = 1 to 20 
@Assign Num[Count, Value] = 0
@Next Value
@Next Count

two nested For Next loops, the first of which uses a step value of 5.

Errors in For/Next commands in procedures will normally be fully reported by the command interpreter. However, this is not the case when you include a For/Next command as part of embedded text in a graphical dialog or report. An error here, such as a spelling mistake in a variable name or a syntax error, would just result in the command lines appearing as text.

The @For command can also be used in reports.

@For/Next, @While/Wend and @Repeat/Until - there is a maximum of 10 nested loops for each of these commands (a combination of these commands can provide up to 30 nested loops).